//
//  HeaderView.m
//  仿微信朋友圈
//
//  Created by dllo on 16/9/3.
//  Copyright © 2016年 DM.C. All rights reserved.
//

#import "HeaderView.h"
#import "SDAutoLayout.h"
#import "TAMacro.h"
@interface HeaderView ()

@end

@implementation HeaderView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createLayout];
    }
    return self;
}
- (void)createLayout {
    self.picImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Expression_101"]];
    
    self.timeLabel = [[UILabel alloc] init];
    //    self.imagesArr = [NSMutableArray array];
    self.userNameLabel = [UILabel new];
    // 添加到View上
    [self addSubview:_picImageView];
    [self addSubview:_timeLabel];
    [self addSubview:_userNameLabel];
    // 头像约束
    self.picImageView.sd_layout
    .leftSpaceToView(self, 10)
    .topSpaceToView(self, 10)
    .widthRatioToView(self, 0.1)
    .autoHeightRatio(1);
    self.picImageView.backgroundColor = [UIColor colorWithRed:0.000 green:0.502 blue:0.502 alpha:1.000];
    self.picImageView.layer.cornerRadius = (SCREEN_WIDTH - 10) * 0.05;
    self.picImageView.layer.masksToBounds = YES;
    
    
    // 用户名约束
    self.userNameLabel.text = @"用户名";
    //    self.userNameLabel.backgroundColor = [UIColor redColor];
    self.userNameLabel.sd_layout
    .centerYEqualToView(self.picImageView)
    .leftSpaceToView(self.picImageView, 3)
    .widthRatioToView(self, 0.5)
    .heightIs(30);
    self.userNameLabel.font = [UIFont systemFontOfSize:14];
    
    // 时间label约束
    self.timeLabel.text = @"18小时前";
    //    self.timeLabel.backgroundColor = [UIColor redColor];
    self.timeLabel.textAlignment = NSTextAlignmentRight;
    self.timeLabel.font = [UIFont systemFontOfSize:13];
    self.timeLabel.textColor = [UIColor colorWithWhite:0.600 alpha:1.000];
    self.timeLabel.sd_resetLayout
    .rightSpaceToView(self, 10)
    .widthRatioToView(self, 0.33)
    .heightIs(30)
    .centerYEqualToView(self.picImageView);
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
}







/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
